#version 450 core

layout(location = 0) in vec3 positionOS;
layout(location = 1) in vec3 normalOS;
layout(location = 2) in vec2 uv;

layout(std140, binding = 0) uniform PerDraw
{
    mat4 viewMatrix;
    mat4 projMatrix;
    vec3 cameraPos;
};
layout(std140, binding = 3) uniform PerObject
{
    mat4 modelMatrix;
};

out Varyings
{
    vec3 positionWS;
    vec3 normalWS;
    vec2 uv;
} o;

void main()
{
    o.positionWS = (modelMatrix * vec4(positionOS, 1.0)).xyz;
    /// 这个是一个均匀缩放，所以直接用顶点矩阵，省去transpose(inverse())
    o.normalWS = mat3(modelMatrix) * normalOS;
    o.uv = uv;
    gl_Position = projMatrix * viewMatrix * vec4(o.positionWS, 1.0);
}
